"""
# --- 安装
!pip install pytest-html

# --- 运行测试案例
python drafts/run_tests.py
"""

from tools.change_cwd_to_main import change_cwd_to_main


change_cwd_to_main()


import os


target_dir_path = 'tests'
# target_file_name = 'test_流程基础类.py'
target_file_name = 'test_processing_cls.py'

# _target_file_name = target_file_name.replace('.', '__')
_target_file_name = os.path.splitext(target_file_name)[0]
target_file_path = os.path.join(target_dir_path, target_file_name)

output_path = os.path.join('tempdir', target_dir_path, _target_file_name, f'report.html')

assert os.path.exists(target_file_path)

# cmd = f'pytest --capture=sys -s --html={output_path}'
cmd = f'pytest --html="{output_path}"'

if target_file_path:
    cmd += f' "{target_file_path}"'


os.system(cmd)


os.system(f'open "{output_path}"')


